﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace StarcraftDemo4
{
    class GameOptimizer
    {
        public static void PlayBaseGames(int num_games = 1)
        {
            int i;
            for (i = 0; i <= num_games; i++)
            {
                SingleGame TestGame = new SingleGame();

                AutoPlayer Scott = new AutoPlayer();

                State GameState = TestGame.PlayAutoGame(Scott);

                List<Move> myGameMoves = TestGame.MovesPlayed;

                //this creates a file with name Recorder.datFileName
                Recorder.SerializeMoves(myGameMoves);
                int GameId;
                //this sends the moves to the db. 
                Recorder.SendToDB(GameState, out GameId);
                Console.WriteLine("{0} is gameid", GameId);
                Console.WriteLine("*******************");
                //this does what it says.
                //string filename = Recorder.GetBinaryFileFromDB(10);
                //Console.WriteLine("{0} is the filename", filename);
                //this recovers the list of moves from the file.
                //List<Move> myRecoveredGameMoves = (List<Move>)Recorder.DeserializeMoves(filename);
            }
            File.Delete(Recorder.datFileName);
        }
    }
}
